﻿using ASmile.DBModel;

namespace ASmile.Com.Da
{
    public class CfgDictBLL : BLLBase, ICfgDictBLL
    {
        public ApiResultList<Cfg_Dict> GetCfgDicts(string cfgType)
        {
            var rList = DB.Query<Cfg_Dict>(s => s.CfgType == cfgType).ToList();
            return RetOK(rList, 0, "OK");
        }

        public ApiResultList<Cfg_DictType> GetCfgDictType()
        {
            var rList = DB.Query<Cfg_DictType>(s => true).ToList();
            return RetOK(rList, 0, "OK");
        }

        public ApiResult<string> SaveCfgValue(Cfg_Dict model)
        {
            Cfg_Dict m = new Cfg_Dict
            {
                CfgId = model.CfgId,
                CfgValue = model.CfgValue,
                CfgCaption = model.CfgCaption,
                Remark = model.Remark
            };
            var r = DB.Update(m);
            if (r.RowCount == 1)
            {
                return RetOK(model.CfgId, "保存成功");
            }
            else
            {
                return RetErr<string>("保存失败");
            }
        }
    }
}